#34 new
Ben Kimball

Three spec failures, all datetime-related

Reported by Ben Kimball | January 14th, 2009 @ 10:43 PM

After generating with ./script/generate authenticated member session --include-activation --rspec I'm seeing three failures when I run rake spec:models:

1) 'Member remembers me default two weeks' FAILED
expected true, got false

'Member remembers me until one week' FAILED
expected: Thu Jan 22 04:20:15 UTC 2009,
   got: Thu, 22 Jan 2009 04:20:15 UTC +00:00 (using ==)

'Member remembers me for one week' FAILED
expected true, got false

That second one in particular looks suspiciously like a database problem to me. I tried adding :db to the remember_token_expires_at: field of the quentin: member fixture but that has no effect on the failure.

I'm on Mac OS X 10.5.6 using rails 2.2.2, sqlite3 3.4.0, rspec 1.1.12, rspec-rails 1.1.12, and sqlite-ruby 1.2.1. My test.log file is attached in case it's helpful. Line 591 is where it starts updating remember_token_expires_at.

Comments and changes to this ticket

  • foleyflex

    foleyflex January 17th, 2009 @ 10:27 AM

    Happened to me as well...a couple of workarounds: 1. Adding the :db to the remember_token_expires_at: field of the quentin: user fixture (users.yml) is VERY important. In some installs of mysql I tested, this would cause all model specs to fail (Could be version of mysql or how its configured...haven't determined).

    1. For the failure on line 211 above, I switched from using '==' to using should.eql? time. The == seems to evaluate the output, the eql? seems to compare actual time values. This is important because after storing the time value in the quentin object, it spits it back in rfc822 format on output.

    2. I've been having issues with the between? method in rspec. It seems to fail in some instances when called programatically, but when I test it in the console, it never fails...possible minor deviations in ruby acquiring system time (I'm on a Windows box). I worked around by outputting the datetime stamps as a date...testing the cookie to expire to the second wasn't that important for me.

  • foleyflex

    foleyflex January 17th, 2009 @ 10:29 AM

    Wow...my comments got munged..oh well, the point it made.

  • Ben Kimball

    Ben Kimball January 17th, 2009 @ 09:12 PM

    Ah, thanks foleyflex.

    The problem is definitely in the date comparison algorithm; I think between? must use '>', '<', and/or '==' internally.

    I managed to fix the test failures (in a kind of fragile way) with this:

    it 'remembers me for one week' do
      timeout = 1.week.from_now.utc
      members(:quentin).remember_me_for 1.week
      members(:quentin).remember_token.should_not be_nil
      members(:quentin).remember_token_expires_at.should_not be_nil
      members(:quentin).remember_token_expires_at.should.eql? timeout

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Restful Authentication Generator

This widely-used plugin provides a foundation for securely managing user
* Login / logout
* Secure password handling
* Account activation by validating email
* Account approval / disabling by admin
* Rudimentary hooks for authorization and access control.


People watching this ticket